package com.loeng.framework.common.enums;

import com.loeng.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author loeng zhuo
 */
@Getter
@AllArgsConstructor
public enum CommonStatusEnum implements ArrayValuable<Integer> {

    // 枚举
    ENABLE(0, "开启"),
    DISABLE(1, "关闭");

    /**
     * 转成数组
     */
    public static final Integer[] ARRAYS = Arrays.stream(values()).map(CommonStatusEnum::getStatus).toArray(Integer[]::new);

    /**
     * 状态值
     */
    private final Integer status;
    /**
     * 状态名
     */
    private final String name;

    @Override
    public Integer[] array() {
        return ARRAYS;
    }

    public static boolean isEnable(Integer status) {
        return Objects.equals(status, ENABLE.getStatus());
    }

    public static boolean isDisable(Integer status) {
        return Objects.equals(status, DISABLE.getStatus());
    }
}
